package cn.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.crypto.Data;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;

import cn.common.ConfigOption;
import cn.common.DocumentHandler;
import cn.common.ExceResult;
import cn.common.GridCommon;
import cn.common.LayTable;
import cn.filter.LoginCheck;
import cn.kpi.dao.usualassessment.UserUATPjDao;
import cn.kpi.entity.attendance.AttDetailEntity;
import cn.kpi.entity.attendance.AttSummaryEntity;
import cn.kpi.entity.sys.OrgEntity;
import cn.kpi.entity.sys.UserEntity;
import cn.kpi.entity.usualassessment.UserUATBmTjEntity;
import cn.kpi.entity.usualassessment.UserUATMzpdEntity;
import cn.kpi.entity.usualassessment.UserUATMzpdSummaryEntity;
import cn.kpi.entity.usualassessment.UserUATPjSummaryEntity;
import cn.kpi.entity.usualassessment.UserUATQzEntity;
import cn.kpi.entity.usualassessment.UserUATZpAtt;
import cn.kpi.entity.usualassessment.UserUATZpSummaryEntity;
import cn.kpi.entity.usualassessment.UserUsAssTempEntity;
import cn.kpi.entity.vtiondpline.VtDpUserListEntity;
import cn.kpi.service.attendance.IAttTbService;
import cn.kpi.service.pingyou.IPyResultService;
import cn.kpi.service.sys.IOrgService;
import cn.kpi.service.sys.IUserService;
import cn.kpi.service.usualassessment.IUserUATMzpdService;
import cn.kpi.service.usualassessment.IUserUATZpService;
import cn.kpi.service.vtiondpline.IVtDpUserService;

@Controller
@RequestMapping("useruatmzpd")
public class UserUATMzpdController extends BaseController {

    @Autowired
    private IUserUATMzpdService iUserUATMzpdService;

    @Autowired
    private IUserService iUserService;

    @Autowired
    private IUserUATZpService iUserUATZpService;

    @Autowired
    private IAttTbService iAttTbService;

    @Autowired
    private UserUATPjDao userUATPjDao;

    @Autowired
    private IPyResultService iPyResultService;

    @Autowired
    private IOrgService iOrgService;

    @Autowired
    private IVtDpUserService iVtDpUserService;

    @RequestMapping(value = "/user_usasstemp_mzpd_list")
    public String UserUsassTempMzpdList(Model model) {
        try {
            Calendar cal = Calendar.getInstance();
            int year = cal.get(Calendar.YEAR);
            int month = cal.get(Calendar.MONTH) + 1;
            int quarter = 1;
            switch (month) {
                case 1:
                case 2:
                case 3:
                    quarter = 1;
                    break;
                case 4:
                case 5:
                case 6:
                    quarter = 2;
                    break;
                case 7:
                case 8:
                case 9:
                    quarter = 3;
                    break;
                case 10:
                case 11:
                case 12:
                    quarter = 4;
                    break;
            }
            if (quarter == 1) {
                year=year-1;
                quarter=4;
            } else {
                quarter = quarter - 1;
            }

            model.addAttribute("year", year);
            model.addAttribute("quarter", quarter);
            UserEntity userEntity = this.GetLoginUser();
            if (userEntity.getRealname().contains("开发")) {

                model.addAttribute("isadmin", true);
            } else {
                model.addAttribute("isadmin", false);

            }
        } catch (Exception ex) {

        }
        return "usualassessment/user_usasstemp_mzpd_list";
    }

    @RequestMapping(value = "/user_usasstemp_mzpd_edit")
    public String UserUsassTempMzpdEdit(Model model) {
        try {
            Calendar cale = Calendar.getInstance();
            int year = cale.get(Calendar.YEAR);
            model.addAttribute("year", year);
            String where = this.GetLoginUserForUserListWhere();
            List<UserEntity> userlst = iUserService.GetUserListByWhere(where);
            model.addAttribute("userlst", userlst);
        } catch (Exception ex) {

        }
        return "usualassessment/user_usasstemp_mzpd_edit";
    }

    @RequestMapping(value = "/user_usasstemp_mzpd_edit_show")
    public String UserUsassTempMzpdEditShow(Model model, int year, int quarter, Long userid) {
        try {
            UserUATMzpdEntity entity = new UserUATMzpdEntity();
            entity.setUserid(userid);
            entity.setYear(year);
            entity.setQuarter(quarter);


            UserEntity user = iUserService.GetUserById(userid);


//            UserUATZpSummaryEntity zp = iUserUATZpService.GetUserUATZpSummaryForMzpd(userid, year, quarter);
//
//            if (zp == null) {
//                model.addAttribute("error", "该人员未完成自评");
//                return "usualassessment/user_usasstemp_mzpd_edit_show";
//            }
//
//            UserUATQzEntity qz = iUserUATMzpdService.GetQzByStatus();
//
//            if (qz == null) {
//                model.addAttribute("error", "未设置权重");
//                return "usualassessment/user_usasstemp_mzpd_edit_show";
//            }
//
//            UserUATPjSummaryEntity hp = userUATPjDao.GetUserUATPjSummaryForMzpd(userid, year, quarter, 0);
//
//            if (hp == null) {
//                model.addAttribute("error", "未完成互评");
//                return "usualassessment/user_usasstemp_mzpd_edit_show";
//            }
//
//            UserUATPjSummaryEntity ld = userUATPjDao.GetUserUATPjSummaryForMzpd(userid, year, quarter, 1);
//
//            if (ld == null) {
//                model.addAttribute("error", "主管/领导未完成评分");
//                return "usualassessment/user_usasstemp_mzpd_edit_show";
//            }

            entity.setRealname(user.getRealname());
            entity.setZzmm(user.getZzmm());
            entity.setGzdw(user.getOrgname());
            entity.setZw("");
            entity.setCsgz("");
            String zq = "";
            String whereatt = " AND year=" + year + " AND userid=" + userid;
            switch (quarter) {
                case 1:
                    zq = year + "年1月1日-" + year + "年3月31日";
                    whereatt += " AND mouth IN(1,2,3)";
                    break;
                case 2:
                    zq = year + "年4月1日-" + year + "年6月30日";
                    whereatt += " AND mouth IN(4,5,6)";
                    break;
                case 3:
                    zq = year + "年7月1日-" + year + "年9月30日";
                    whereatt += " AND mouth IN(7,8,9)";
                    break;
                case 4:
                    zq = year + "年10月1日-" + year + "年12月31日";
                    whereatt += " AND mouth IN(10,11,12)";
                    break;
            }


            AttSummaryEntity att = iAttTbService.GetAttTbSummaryByWhereForMzpd(whereatt);

            if (att == null) {
                model.addAttribute("error", "未填报考勤");
                return "usualassessment/user_usasstemp_mzpd_edit_show";
            }

            entity.setKhzq(zq);
//            entity.setGzyj(zp.getGzyj());
//            entity.setCzbz(zp.getCzwt());
//            entity.setZpjg(zp.getZpjg());

            entity.setKqcqts(att.getCqts());
            entity.setKqjbts(att.getJbts());
            entity.setKqxjts(att.getXjts());
            entity.setKqbsjts(att.getBsjts());
            entity.setKqgsycjts(att.getGsycjts());
            entity.setKqcdcc(att.getCdcc());
            entity.setKqztcc(att.getZtcc());
            entity.setKqkgcc(att.getKgcs());

//            entity.setHpqz(qz.getHpqz());
//            entity.setLdqz(qz.getLdqz());

            //int hpdf=(qz.getHpqz()*hp.getTotalscore())/100;
//            Float hpdf = (qz.getHpqz() * hp.getTotalscore()) / (100f);
//            entity.setNbhpdf(hpdf);
            //int ldpydf=(qz.getLdqz()*ld.getTotalscore())/100;
//            Float ldpydf = (qz.getLdqz() * ld.getTotalscore()) / (100f);
//            entity.setLdpjdf(ldpydf);
//            entity.setLdpynr(ld.getPynr());

//            entity.setPskhzhdf(hpdf + ldpydf);


            model.addAttribute("entity", entity);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        model.addAttribute("error", "");
        return "usualassessment/user_usasstemp_mzpd_edit_show";
    }


    @RequestMapping(value = "/user_usasstemp_mzpd_edit_new")
    public String UserUsassTempMzpdEditNew(Model model, int year, int quarter, Long userid, Long mzpdid) {
        try {
            UserUATMzpdEntity entity = new UserUATMzpdEntity();
            if (mzpdid > 0) {
                entity = iUserUATMzpdService.GetMzpdListById(mzpdid);

            } else {
                entity.setUserid(userid);
                entity.setYear(year);
                entity.setQuarter(quarter);

                UserUATQzEntity qz = iUserUATMzpdService.GetQzByStatus();
                if (qz == null) {
                    model.addAttribute("error", "未设置权重");
                    return "usualassessment/user_usasstemp_mzpd_edit_new";
                }

                UserEntity user = iUserService.GetUserById(userid);
                UserUATZpSummaryEntity zp = iUserUATZpService.GetUserUATZpSummaryForMzpd(userid, year, quarter);

                if (zp == null) {
                    model.addAttribute("error", "该人员未完成自评");
                    return "usualassessment/user_usasstemp_mzpd_edit_new";
                } else {
                    int zpstatus = zp.getStatus();
                    if (zpstatus != 1) {
                        model.addAttribute("error", "自评结果未提交");
                        return "usualassessment/user_usasstemp_mzpd_edit_new";
                    }

                    entity.setGzyj(zp.getGzyj());
                    entity.setCzbz(zp.getCzwt());
                }
                UserUATPjSummaryEntity hp = userUATPjDao.GetUserUATPjSummaryForMzpd(userid, year, quarter, 0);
                if (hp == null) {
                    model.addAttribute("error", "未完成互评");
                    return "usualassessment/user_usasstemp_mzpd_edit_new";
                } else {
                    int hpstatus = hp.getStatus();
                    if (hpstatus != 1) {
                        model.addAttribute("error", "互评结果未提交");
                        return "usualassessment/user_usasstemp_mzpd_edit_new";
                    }
                }
//
                UserUATPjSummaryEntity ld = userUATPjDao.GetUserUATPjSummaryForMzpd(userid, year, quarter, 1);
                if (ld == null) {
                    model.addAttribute("error", "主管/领导未完成评分");
                    return "usualassessment/user_usasstemp_mzpd_edit_new";
                } else {
                    int ldstatus = ld.getStatus();
                    if (ldstatus != 1) {
                        model.addAttribute("error", "领导评定结果未提交");
                        return "usualassessment/user_usasstemp_mzpd_edit_new";
                    }
                }

                entity.setRealname(user.getRealname());
                entity.setZzmm(user.getZzmm());
                entity.setGzdw(user.getOrgname());
                entity.setZw("");
                entity.setCsgz("");
                String zq = "";
                String whereatt = " AND year=" + year + " AND userid=" + userid;
                switch (quarter) {
                    case 1:
                        zq = year + "年1月1日-" + year + "年3月31日";
                        whereatt += " AND mouth IN(1,2,3)";
                        break;
                    case 2:
                        zq = year + "年4月1日-" + year + "年6月30日";
                        whereatt += " AND mouth IN(4,5,6)";
                        break;
                    case 3:
                        zq = year + "年7月1日-" + year + "年9月30日";
                        whereatt += " AND mouth IN(7,8,9)";
                        break;
                    case 4:
                        zq = year + "年10月1日-" + year + "年12月31日";
                        whereatt += " AND mouth IN(10,11,12)";
                        break;
                }
                whereatt += " AND status=2";

                AttSummaryEntity att = iAttTbService.GetAttTbSummaryByWhereForMzpd(whereatt);
//
//                if (att == null) {
//                    model.addAttribute("error", "未填报考勤");
//                    return "usualassessment/user_usasstemp_mzpd_edit_new";
//                }
//
//                List<AttSummaryEntity> attlist = iAttTbService.GetAttTbSummaryListByWhereForMzpd(whereatt);
//                if (attlist.size() != 3) {
//                    model.addAttribute("error", "考勤数据不完整");
//                    return "usualassessment/user_usasstemp_mzpd_edit_new";
//                }

                String uatattwhere = " AND userid=" + userid + " AND year=" + year + " AND quarter=" + quarter;
                UserUATZpAtt useruatatt = iUserUATZpService.GetUserUATZpAttByWhere(uatattwhere);

                entity.setKhzq(zq);
                entity.setGzyj(zp.getGzyj());
                entity.setCzbz(zp.getCzwt());
                entity.setZpjg(zp.getZpjg());
                if (att != null) {
                    entity.setKqcqts(att.getCqts());
                    entity.setKqjbts(att.getJbts());
                    entity.setKqxjts(att.getXjts());
                    entity.setKqbsjts(att.getBsjts());
                    entity.setKqgsycjts(att.getGsycjts());
                    entity.setKqcdcc(att.getCdcc());
                    entity.setKqztcc(att.getZtcc());
                    entity.setKqkgcc(att.getKgcs());

                }

                if (useruatatt != null) {
                    entity.setKqcqts(useruatatt.getCqts());
                    entity.setKqjbts(useruatatt.getJbts());
                    entity.setKqxjts(useruatatt.getNxjts());
                    entity.setKqbsjts(useruatatt.getBjts() + useruatatt.getSjts());
                    entity.setKqgsycjts(useruatatt.getGsts() + useruatatt.getSyjts());
                    entity.setKqcdcc(useruatatt.getCdcc());
                    entity.setKqztcc(useruatatt.getZtcc());
                    entity.setKqkgcc(useruatatt.getKgcs());

                }

                entity.setHpqz(qz.getHpqz());
                entity.setLdqz(qz.getLdqz());
                //int hpdf=(qz.getHpqz()*hp.getTotalscore())/100;
                Float hpdf = (qz.getHpqz() * hp.getTotalscore()) / (100f);
                entity.setNbhpdf(hpdf);
//                float ldpydf=(qz.getLdqz()*ld.getTotalscore())/100;
                Float ldpydf = (qz.getLdqz() * ld.getTotalscore()) / (100f);
                entity.setLdpjdf(ldpydf);
                entity.setLdpynr(ld.getPynr());
                entity.setPskhzhdf(hpdf + ldpydf);
            }

            model.addAttribute("mzpdid", mzpdid);
            model.addAttribute("entity", entity);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        model.addAttribute("error", "");
        return "usualassessment/user_usasstemp_mzpd_edit_new";
    }

    @RequestMapping(value = "/user_usasstemp_mzpd_data_checked")
    public String UserUsassTempMzpdDataChecked(Model model, int year, int quarter, Long userid, Long mzpdid) {
        try {
            model.addAttribute("year", year);
            model.addAttribute("quarter", quarter);
            model.addAttribute("userid", userid);
            model.addAttribute("mzpdid", mzpdid);
            UserEntity user = iUserService.GetUserById(userid);
            model.addAttribute("userentity", user);
        } catch (Exception ex) {

        }
        return "usualassessment/user_usasstemp_mzpd_data_checked";
    }


    @RequestMapping(value = "/user_usasstemp_qz_list")
    public String UserUsassTempQzList(Model model) {
        try {
            UserUATQzEntity qzentity = iUserUATMzpdService.GetQzByStatus();
            if (qzentity == null) {
                qzentity = new UserUATQzEntity();
                qzentity.setByuserid(0L);
                qzentity.setHpqz(0);
                qzentity.setLdqz(0);
                qzentity.setStatus(0);
                qzentity.setQzid(0L);
            }
            model.addAttribute("qzentity", qzentity);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return "usualassessment/user_usasstemp_qz_list";
    }

    @RequestMapping(value = "/user_usasstemp_mzpd_detail")
    public String UserUsassTempMzpdDetail(Model model, Long mzpdid) {
        try {
            UserUATMzpdEntity entity = iUserUATMzpdService.GetMzpdListById(mzpdid);
            model.addAttribute("entity", entity);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return "usualassessment/user_usasstemp_mzpd_detail";
    }

    @RequestMapping(value = "/user_usasstemp_mzpd_summary")
    public String UserUsassTempMzpdSummary(Model model) {
        try {
            UserEntity user = iUserService.GetUserById(this.GetLoginUserId());
            String orgids = this.GetOrgListByRole();
            if (orgids.split(",").length == 1) {
                Calendar cal = Calendar.getInstance();
                int year = cal.get(Calendar.YEAR);
                UserUATBmTjEntity tj = iUserUATMzpdService.GetBmTj(year, user.getSzdw());
                model.addAttribute("tjentity", tj);
            }
            model.addAttribute("user", user);
            String where = " AND orgid IN (" + orgids + ")";
            List<OrgEntity> orglst = iOrgService.GetOrgListByWhere(where);
            for (int i = 0; i < orglst.size(); i++) {
                String html = "";
                for (int j = 0; j < orglst.get(i).getLevel(); j++) {
                    html += "&#12288;";
                }
                orglst.get(i).setOrgname(html + orglst.get(i).getOrgname());
            }
            model.addAttribute("orglst", orglst);

            Calendar cale = Calendar.getInstance();
            int year = cale.get(Calendar.YEAR);
            year =year -1;
            model.addAttribute("year", year);

        } catch (Exception ex) {

        }
        return "usualassessment/user_usasstemp_mzpd_summary";
    }

    @RequestMapping(value = "/user_usasstemp_mzpd_hz_list")
    public String UserUsassTempMzpdHzList(Model model) {
        try {
            Calendar cal = Calendar.getInstance();
            int year = cal.get(Calendar.YEAR);
            int month = cal.get(Calendar.MONTH) + 1;
            int quarter = 1;
            switch (month) {
                case 1:
                case 2:
                case 3:
                    quarter = 1;
                    break;
                case 4:
                case 5:
                case 6:
                    quarter = 2;
                    break;
                case 7:
                case 8:
                case 9:
                    quarter = 3;
                    break;
                case 10:
                case 11:
                case 12:
                    quarter = 4;
                    break;
            }
            if (quarter == 1) {
                year=year-1;
                quarter=4;
            } else {
                quarter = quarter - 1;
            }
            model.addAttribute("year", year);
            model.addAttribute("quarter", quarter);
        } catch (Exception ex) {

        }
        return "usualassessment/user_usasstemp_mzpd_hz_list";
    }

    @RequestMapping(value = "/add_useruatqz")
    public String AddUserUATQz(HttpServletRequest request, HttpServletResponse response) {
        try {
            UserUATQzEntity entity = new UserUATQzEntity();
            //entity.setQzid(Long.parseLong(request.getParameter("qzid")));
            entity.setRemark(request.getParameter("remark"));
            entity.setHpqz(Integer.parseInt(request.getParameter("hpqz")));
            entity.setLdqz(Integer.parseInt(request.getParameter("ldqz")));
            entity.setStatus(1);
            entity.setByuserid(this.GetLoginUserId());
            if ((entity.getHpqz() + entity.getLdqz()) > 100) {
                return renderStringScript(response, "<script>window.parent.CloseDialog(0,'权重之和大于100，请修改后重试')</script>");
            }

            int iResult = iUserUATMzpdService.InsertQz(entity);

            return renderStringScript(response, "<script>window.parent.CloseDialog(" + iResult + ")</script>");
        } catch (Exception ex) {
            ex.printStackTrace();
            return renderStringScript(response, "<script>window.parent.CloseDialog(0)</script>");
        }
    }

    @RequestMapping(value = "/add_useruatmzpd")
    public String AddAttTb(HttpServletRequest request, HttpServletResponse response) {
        try {
            boolean isadmin = false;
            UserEntity userEntity = GetLoginUser();
            if (userEntity.getRealname().contains("开发")) {
                isadmin = true;
            }

            String strmzpdid = request.getParameter("mzpdid");
            String struserid = request.getParameter("userid");
            String stryear = request.getParameter("year");
            String strquarter = request.getParameter("quarter");
            if (struserid == null || struserid.length() <= 0) {
                return renderStringScript(response, "<script>window.parent.CloseDialog(0,'参数有误')</script>");
            }
            Long mzpdid = Long.parseLong(strmzpdid);
            Long userid = Long.parseLong(struserid);
            UserEntity user = this.GetUserById(userid);//拿到保存用户详细信息
            int year = Integer.parseInt(stryear);
            int quarter = Integer.parseInt(strquarter);
            UserUATMzpdEntity entity = new UserUATMzpdEntity();
            entity.setMzpdid(mzpdid);
            entity.setUserid(userid);
            entity.setYear(year);
            entity.setQuarter(quarter);

            entity.setRealname(request.getParameter("realname"));
            entity.setZzmm(request.getParameter("zzmm"));
            entity.setGzdw(request.getParameter("gzdw"));
            entity.setZw(request.getParameter("zw"));
            entity.setCsgz(request.getParameter("csgz"));
            entity.setKhzq(request.getParameter("khzq"));
            entity.setGzyj(request.getParameter("gzyj"));
            entity.setCzbz(request.getParameter("czbz"));
            entity.setZpjg(request.getParameter("zpjg"));

            entity.setKqcqts(Float.parseFloat(request.getParameter("kqcqts")));
            entity.setKqjbts(Float.parseFloat(request.getParameter("kqjbts")));
            entity.setKqxjts(Float.parseFloat(request.getParameter("kqxjts")));
            entity.setKqbsjts(Float.parseFloat(request.getParameter("kqbsjts")));
            entity.setKqgsycjts(Float.parseFloat(request.getParameter("kqgsycjts")));
            entity.setKqcdcc(Integer.parseInt(request.getParameter("kqcdcc")));
            entity.setKqztcc(Integer.parseInt(request.getParameter("kqztcc")));
            entity.setKqkgcc(Integer.parseInt(request.getParameter("kqkgcc")));

            entity.setHpqz(Integer.parseInt(request.getParameter("hpqz")));
            entity.setLdqz(Integer.parseInt(request.getParameter("ldqz")));

            //固化开始
            entity.setSzdw(user.getSzdw());
            entity.setSzdwname(user.getOrgname());
            entity.setUserstatus(user.getUserstatus());
            entity.setRsgxszdw(user.getRsgxszdw());
            entity.setRsgxszdwname(user.getRsgxorgname());
            //固化结束


//			entity.setNbhpdf(Integer.parseInt(request.getParameter("nbhpdf")));
//			entity.setLdpjdf(Integer.parseInt(request.getParameter("ldpjdf")));
            float  nbhpdf=0;
            if (request.getParameter("nbhpdf") != "") {
                entity.setNbhpdf(Float.parseFloat(request.getParameter("nbhpdf")));
                nbhpdf=entity.getNbhpdf();
            }else{
                return renderStringScript(response, "<script>window.parent.CloseDialog(" + -1 + ")</script>");
            }
             float  ldpjdf=0;
            if (request.getParameter("ldpjdf") != "") {

                entity.setLdpjdf(Float.parseFloat(request.getParameter("ldpjdf")));

                 ldpjdf=entity.getLdpjdf();
            }else {
                return renderStringScript(response, "<script>window.parent.CloseDialog(" + -2 + ")</script>");

            }


            entity.setLdpynr(request.getParameter("ldpynr"));

            //entity.setPskhzhdf(Integer.parseInt(request.getParameter("pskhzhdf")));

                entity.setPskhzhdf(ldpjdf+nbhpdf);

            entity.setZzpdjg(request.getParameter("zzpdjg"));
            entity.setDymzpyjg(request.getParameter("dymzpyjg"));
            entity.setByuserid(this.GetLoginUserId());
            entity.setStatus(0);


            //判断违规违纪
            String vtdpwhere = "";
            switch (entity.getQuarter()) {
                case 0:
//                    vtdpwhere+=" AND begintime>='"+year+"-01-01 00:00:00' AND begintime<='"+year+"-12-31 23:59:59'";
                    //vtdpwhere+=" AND begintime>='"+year+"-01-01 00:00:00' AND begintime<='"+year+"-03-31 23:59:59'";
                    break;
                case 1:
                    vtdpwhere+=" AND endtime>='"+year+"-01-01 00:00:00' AND begintime<='"+year+"-03-31 23:59:59'";
//                    vtdpwhere += "AND (( begintime<='" + year + "-01-01 00:00:00' AND endtime>='" + year + "-01-01 00:00:00') OR ( begintime<='" + year + "-03-31 23:59:59' AND endtime>='" + year + "-03-31 23:59:59')) ";
                    break;
                case 2:
                    vtdpwhere+=" AND endtime>='"+year+"-04-01 00:00:00' AND begintime<='"+year+"-06-30 23:59:59'";
//                    vtdpwhere += " AND (( begintime<='" + year + "-04-01 00:00:00' AND endtime>='" + year + "-04-01 00:00:00') OR ( begintime<='" + year + "-06-30 23:59:59' AND endtime>='" + year + "-06-30 23:59:59')) ";
                    break;
                case 3:
                    vtdpwhere+=" AND endtime>='"+year+"-07-01 00:00:00' AND begintime<='"+year+"-09-30 23:59:59'";
//                    vtdpwhere += "AND (( begintime<='" + year + "-07-01 00:00:00' AND endtime>='" + year + "-07-01 00:00:00') OR ( begintime<='" + year + "-09-30 23:59:59' AND endtime>='" + year + "-09-30 23:59:59')) ";
                    break;
                case 4:
                    vtdpwhere+=" AND endtime>='"+year+"-10-01 00:00:00' AND begintime<='"+year+"-12-31 23:59:59'";
//                    vtdpwhere += "AND (( begintime<='" + year + "-10-01 00:00:00' AND endtime>='" + year + "-10-01 00:00:00') OR ( begintime<='" + year + "-12-31 23:59:59' AND endtime>='" + year + "-12-31 23:59:59')) ";
                    break;
            }


            List<VtDpUserListEntity> lst = iVtDpUserService.GetVtDpListByUseridAndWhere(userid, vtdpwhere);
            //System.out.println(JSON.toJSONString(lst));
            //System.out.println(JSON.toJSONString(entity));
            for (int i = 0; i < lst.size(); i++) {
                VtDpUserListEntity item = lst.get(i);
                String zzpdcllx = item.getZzpdcllx();
                String mzpdcllx = item.getMzpdcllx();
                switch (zzpdcllx) {
                    case "不参加考核":
                        return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项限定不参加考核')</script>");
                    //break;
                    case "无限定":
                        break;
                    case "不能为好":
                        if (entity.getZzpdjg().equals("好")) {
                            return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项限定组织评定结果不能为好')</script>");
                        }
                        break;
                    case "不能为合格":
                        if (entity.getZzpdjg().equals("合格")) {
                            return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项限定组织评定结果不能为合格')</script>");
                        }
                        break;
                    case "评为差":
                        if (!entity.getZzpdjg().equals("差")) {
                            return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项限定组织评定结果需评为差')</script>");
                        }
                        break;
                    case "评为不定结果":
                        if (!entity.getZzpdjg().equals("不定结果")) {
                            return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项限定组织评定结果需评为不定结果')</script>");
                        }
                        break;
                }

                switch (mzpdcllx) {
                    case "不参加考核":
                        return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项限定不参加考核')</script>");
                    //break;
                    case "无限定":
                        break;
                    case "确定为优秀":
                        if (!entity.getDymzpyjg().equals("优秀")) {
                            return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项党员民主评议结果确定为优秀')</script>");
                        }
                        break;
                    case "确定为合格":
                        if (!entity.getDymzpyjg().equals("合格")) {
                            return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项党员民主评议结果确定为合格')</script>");
                        }
                        break;
                    case "确定为基本合格":
                        if (!entity.getDymzpyjg().equals("基本合格")) {
                            return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项党员民主评议结果确定为基本合格')</script>");
                        }
                        break;
                    case "确定为不合格":
                        if (!entity.getDymzpyjg().equals("不合格")) {
                            return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项党员民主评议结果确定为不合格')</script>");
                        }
                        break;
                    case "确定为不定等次":
                        if (!entity.getDymzpyjg().equals("不合格")) {
                            return renderStringScript(response, "<script>window.parent.CloseDialog(0,'该人员特殊事项党员民主评议结果确定为不定等次')</script>");
                        }
                        break;
                }
            }


            if (entity.getZzpdjg().equals("差")) {
                if (entity.getPskhzhdf() > 60) {
                    return renderStringScript(response, "<script>window.parent.CloseDialog(0,'结果为差，综合评分不能高于60')</script>");
                }
            }

            int iResult = 0;
            if (mzpdid > 0) {
                iResult = iUserUATMzpdService.UpdateMzpdEntity(entity);
            } else {
                UserUATMzpdEntity enexit = iUserUATMzpdService.GetMzpdEntityByYQU(entity.getUserid(), entity.getYear(), entity.getQuarter());
                if (enexit != null) {
                    return renderStringScript(response, "<script>window.parent.CloseDialog(0,'本季度已提交过数据，请勿重复提交')</script>");
                }
                iResult = iUserUATMzpdService.InsertMzpdEntity(entity);
            }

            //是系统管理员，并且修改成功
            if(isadmin&&iResult>0){
                iResult += iPyResultService.backDataByStatusGd(year,quarter);//更新固化季度数据
            }


            return renderStringScript(response, "<script>window.parent.CloseDialog(" + iResult + ")</script>");
        } catch (Exception ex) {
            ex.printStackTrace();
            return renderStringScript(response, "<script>window.parent.CloseDialog(0)</script>");
        }
    }

//	@LoginCheck(description = true)
//	@ResponseBody
//	@RequestMapping(value = "/get_list")
//	public LayTable<UserUATMzpdEntity> GetList(HttpServletRequest request) {
//
//		List<UserUATMzpdEntity> lst = null;
//		LayTable<UserUATMzpdEntity> layTable = new LayTable<UserUATMzpdEntity>();
//		try {
//			String year = request.getParameter("year");
//			String quarter = request.getParameter("quarter");
//			String where = "";
//			if(year!=null&&year.length()>0){
//				where+=" AND year="+year;
//			}
//            if(quarter!=null&&quarter.length()>0){
//            	where+=" AND quarter="+quarter;
//			}
//			
//
//            where+=this.GetLoginUserForOtherListWhereByUserId();
//            
//			lst = iUserUATMzpdService.GetMzpdListByWhere(where);
//			for (int i = 0; i < lst.size(); i++) {
//				lst.get(i).setRowNum(i + 1);
//			}
//
//			int iCount = iUserUATMzpdService.GetMzpdListCountByWhere(where);
//			layTable.setCode(0);
//			layTable.setCount(iCount);
//			layTable.setData(lst);
//
//		} catch (Exception e) {
//			layTable.setCode(500);
//		}
//		return layTable;
//	}


    @LoginCheck(description = true)
    @ResponseBody
    @RequestMapping(value = "/get_list")
    public LayTable<UserUATMzpdEntity> GetList(HttpServletRequest request) {

        List<UserUATMzpdEntity> lst = null;
        int iCount = 0 ;
        LayTable<UserUATMzpdEntity> layTable = new LayTable<UserUATMzpdEntity>();
        try {
            String realname = request.getParameter("realname");
            int year = Integer.parseInt(request.getParameter("year"));
            int quarter = Integer.parseInt(request.getParameter("quarter"));
            String strorgid = request.getParameter("orgid");
            String status = request.getParameter("status");

            String where = "";
            int page = Integer.parseInt(request.getParameter("page"));
            int limit = Integer.parseInt(request.getParameter("limit"));
            int beginrow = (page - 1) * limit;
            int endrow = limit;

            where += this.GetUserListByRole();
            if (realname != null && realname.length() > 0) {
                where += " AND realname LIKE '%" + realname + "%'";
            }
            if (strorgid == null) {
                //为空时就获取当前用户
                if(GetLoginUser().getSzdw()!=null)
                    strorgid = GetLoginUser().getSzdw().toString();
            }
            if(strorgid != null&&strorgid.length() > 0){
                where += " AND szdw=" + strorgid;
            }

            //强行获取上级的状态
            if(status == null||status.equals("")){
                String orgwhere = "";
                if (this.GetOrgListByRole() != "") {
                    orgwhere = " AND orgid IN (" + this.GetOrgListByRole() + ")";
                }
                List<Map> list = iUserUATMzpdService.GetPjOrgSumList(orgwhere, year, quarter);
                String notCountBM = "19,44,45,46,47,48";
                for (Map map : list) {
                    if(notCountBM.contains(map.get("orgid").toString())) continue;
                    if(map.get("status") == null){
                        status = "";
                        break;//跳出
                    }else {
                        if(map.get("status").toString().equals("1")){
                            status = "1";
                            break;//跳出
                        }
                        else{
                            status = "2";
                        }
                    }
                }
            }

            //11.1平时考核
            where += " AND userstatus='在职'";

            if(status.equals("2"))//已经归档
            {
                lst = iUserUATMzpdService.GetOldUserMzpdListProcess(where, year, quarter, beginrow, endrow);
                where += " AND quarter ="+quarter;
                iCount = iUserUATMzpdService.GetOldUserMzpdListProcessCount(where);
                //拼接不考核人员
                String noCwhere ="";
                if (strorgid != null && strorgid.length() > 0) {
                    noCwhere += " AND szdw=" + strorgid;
                }

                switch (quarter) {
                    case 0:
                        break;
                    case 1:
                        noCwhere+=" AND uv.endtime>='"+year+"-01-01 00:00:00' AND uv.begintime<='"+year+"-03-31 23:59:59'";
//                    where3 += "AND (( begintime<='" + year + "-01-01 00:00:00' AND endtime>='" + year + "-01-01 00:00:00') OR ( begintime<='" + year + "-03-31 23:59:59' AND endtime>='" + year + "-03-31 23:59:59')) ";
                        break;
                    case 2:
                        noCwhere+=" AND uv.endtime>='"+year+"-04-01 00:00:00' AND uv.begintime<='"+year+"-06-30 23:59:59'";
                        break;
                    case 3:
                        noCwhere+=" AND uv.endtime>='"+year+"-07-01 00:00:00' AND uv.begintime<='"+year+"-09-30 23:59:59'";
                        break;
                    case 4:
                        noCwhere+=" AND uv.endtime>='"+year+"-10-01 00:00:00' AND uv.begintime<='"+year+"-12-31 23:59:59'";
                        break;
                }

                if (strorgid != null && strorgid.length() > 0) {
                    noCwhere += " AND szdw=" + strorgid;
                }
                noCwhere +=" AND (vi.zzpdcllx='不参加考核' OR vi.mzpdcllx='不参加考核') AND status = 1 ";
                List<VtDpUserListEntity> nocheckelst = iVtDpUserService.GetUserVtDpBcjkhList(noCwhere);
                if (realname != null && realname.length() > 0) {
                    for (VtDpUserListEntity entity : nocheckelst) {
                        if(entity.getRealname().contains(realname)) {
                            UserUATMzpdEntity uu = new UserUATMzpdEntity();
                            uu.setRealname(entity.getRealname());
                            uu.setSzdw(entity.getOrgid());
                            uu.setOrgname(entity.getOrgname());
                            uu.setCardno(entity.getCardno());
                            uu.setYear(year);
                            uu.setUserid(entity.getUserid());
                            uu.setQuarter(quarter);
                            uu.setWjcount(1L);
                            lst.add(uu);
                        }
                    }
                }else {
                    for (VtDpUserListEntity entity : nocheckelst) {
                        UserUATMzpdEntity uu = new UserUATMzpdEntity();
                        uu.setRealname(entity.getRealname());
                        uu.setSzdw(entity.getOrgid());
                        uu.setOrgname(entity.getOrgname());
                        uu.setCardno(entity.getCardno());
                        uu.setYear(year);
                        uu.setUserid(entity.getUserid());
                        uu.setQuarter(quarter);
                        uu.setWjcount(1L);
                        lst.add(uu);
                    }
                }
                iCount += nocheckelst.size();
                //拼接结束

            }else {
                lst = iUserUATMzpdService.GetUserMzpdListProcess(where, year, quarter, beginrow, endrow);
                iCount = iUserUATMzpdService.GetUserMzpdListProcessCount(where);
            }

            for (int i = 0; i < lst.size(); i++) {
                int numr = (page - 1) * limit + (i + 1);
                lst.get(i).setRowNum(numr);

                String realorgName = lst.get(i).getRealorgname();
                if (realorgName == null || realorgName.equals("")) {
                    lst.get(i).setRealorgname(lst.get(i).getOrgname());
                }
            }

            layTable.setCode(0);
            layTable.setCount(iCount);
            layTable.setData(lst);

        } catch (Exception e) {
            layTable.setCode(500);
        }
        return layTable;
    }

    @ResponseBody
    @RequestMapping(value = "/delete_mzpd")
    public ExceResult DeleteMzpd(HttpServletRequest request, HttpServletResponse response) {
        ExceResult result = new ExceResult();
        result.setCode(400);
        result.setResult(0);
        try {
            Long mzpdid = Long.parseLong(request.getParameter("mzpdid"));
            int iResult = iUserUATMzpdService.DeleteMzpdEntity(mzpdid);
            if (iResult > 0) {
                result.setCode(200);
                result.setResult(iResult);
                result.setMsg("操作成功");
            } else {
                result.setCode(300);
                result.setResult(iResult);
                result.setMsg("操作失败");
            }
        } catch (Exception ex) {
            result.setCode(500);
            result.setResult(0);
            result.setMsg("操作异常");
        }
        return result;
    }


    @LoginCheck(description = true)
    @ResponseBody
    @RequestMapping(value = "/get_summary_list")
    public LayTable<UserUATMzpdSummaryEntity> GetSummaryList(HttpServletRequest request) {

        List<UserUATMzpdSummaryEntity> lst = null;
        LayTable<UserUATMzpdSummaryEntity> layTable = new LayTable<UserUATMzpdSummaryEntity>();
        try {
            int year = Integer.parseInt(request.getParameter("year"));
            String zzpdjg = request.getParameter("zzpdjg");
            String dymzpyjg = request.getParameter("dymzpyjg");
            String szdw = request.getParameter("szdw");
            String where = "";

            if (zzpdjg != null && zzpdjg.length() > 0) {
                where += " AND (B.yzzpdjg='" + zzpdjg + "' OR B.ezzpdjg='" + zzpdjg + "' OR B.szzpdjg='" + zzpdjg + "' OR B.sizzpdjg='" + zzpdjg + "') ";
            }
            if (dymzpyjg != null && dymzpyjg.length() > 0) {
                where += " AND (B.ydymzpyjg='" + dymzpyjg + "' OR B.edymzpyjg='" + dymzpyjg + "' OR B.sdymzpyjg='" + dymzpyjg + "' OR B.sidymzpyjg='" + dymzpyjg + "') ";
            }

            UserEntity userentity = this.GetLoginUser();


            where += " AND A.szdw=" + szdw;

            String orgids = this.GetOrgListByRole();

            // where+=" AND A.szdw IN ("+orgids+") ";

            if (orgids.split(",").length == 1) {
//				Calendar cal = Calendar.getInstance();
//				int year = cal.get(Calendar.YEAR);
//				UserUATBmTjEntity tj = iUserUATMzpdService.GetBmTj(year, user.getSzdw());
//				model.addAttribute("tjentity", tj);

            } else {

            }

            // where+=" AND A.szdw="+userentity.getSzdw();

            //todo:评议结果查询固化
            lst = iUserUATMzpdService.GetMzpdSummaryListByWhere(where, year);
            for (int i = 0; i < lst.size(); i++) {
                lst.get(i).setRowNum(i + 1);
            }

            int iCount = iUserUATMzpdService.GetMzpdSummaryListCountByWhere(where, year);
            layTable.setCode(0);
            layTable.setCount(iCount);
            layTable.setData(lst);

        } catch (Exception e) {
            layTable.setCode(500);
        }
        return layTable;
    }

    @ResponseBody
    @RequestMapping(value = "/update_mzpdsummarystatus")
    public ExceResult UpdateMzpdSummaryStatus(HttpServletRequest request, HttpServletResponse response) {
        ExceResult result = new ExceResult();
        result.setCode(400);
        result.setResult(0);
        try {
            Long mzpdsummaryid = Long.parseLong(request.getParameter("mzpdsummaryid"));
            int iResult = iPyResultService.UpdateMzpdSummaryStatusById(mzpdsummaryid, 1);
            if (iResult > 0) {
                result.setCode(200);
                result.setResult(iResult);
                result.setMsg("操作成功");
            } else {
                result.setCode(300);
                result.setResult(iResult);
                result.setMsg("操作失败");
            }
        } catch (Exception ex) {
            result.setCode(500);
            result.setResult(0);
            result.setMsg("操作异常");
        }
        return result;
    }


    @ResponseBody
    @RequestMapping(value = "/export_mzpd")
    public ExceResult ExportMzpd(HttpServletRequest request, HttpServletResponse response) {
        ExceResult result = new ExceResult();
        result.setCode(400);
        result.setResult(0);
        try {
            Long mzpdid = Long.parseLong(request.getParameter("mzpdid"));
            UserUATMzpdEntity eResult = iUserUATMzpdService.GetMzpdListById(mzpdid);

            Map<String, String> dataMap = new HashMap<String, String>();
            dataMap.put("realname", eResult.getRealname());
            dataMap.put("zzmm", eResult.getZzmm());
            dataMap.put("gzdw", eResult.getGzdw());
            dataMap.put("zw", eResult.getZw());
            dataMap.put("csgz", eResult.getCsgz());
            dataMap.put("khzq", eResult.getKhzq());
            dataMap.put("gzyj", eResult.getGzyj());
            dataMap.put("czbz", eResult.getCzbz());
            dataMap.put("zpjg", eResult.getZpjg());
            dataMap.put("kqbsjts", String.valueOf(eResult.getKqbsjts()));
            dataMap.put("kqcdcc", String.valueOf(eResult.getKqcdcc()));
            dataMap.put("kqcqts", String.valueOf(eResult.getKqcqts()));
            dataMap.put("kqgsycjts", String.valueOf(eResult.getKqgsycjts()));
            dataMap.put("kqjbts", String.valueOf(eResult.getKqjbts()));
            dataMap.put("kqkgcc", String.valueOf(eResult.getKqkgcc()));
            dataMap.put("kqxjts", String.valueOf(eResult.getKqxjts()));
            dataMap.put("kqztcc", String.valueOf(eResult.getKqztcc()));

            dataMap.put("hpqz", String.valueOf(eResult.getHpqz()));
            dataMap.put("nbhpdf", String.valueOf(eResult.getNbhpdf()));
            dataMap.put("ldqz", String.valueOf(eResult.getLdqz()));
            dataMap.put("ldpjdf", String.valueOf(eResult.getLdpjdf()));
            dataMap.put("ldpynr", eResult.getLdpynr());
            dataMap.put("pskhzhdf", String.valueOf(eResult.getPskhzhdf()));
            dataMap.put("zzpdjg", eResult.getZzpdjg());
            dataMap.put("dymzpyjg", eResult.getDymzpyjg() == null ? "" : eResult.getDymzpyjg());


            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

            DocumentHandler doc = new DocumentHandler();
            String fileName = eResult.getRealname() + "_" + sdf.format(new Date()) + ".doc";
            String filePath = ConfigOption.getInstance().getFileurl() + "/" + fileName;
            String tempfilename = "mzpdtemp.xml";
            Boolean bolResult = doc.createDoc(dataMap, filePath, tempfilename);


            if (bolResult) {
                String url = ConfigOption.getInstance().getWeburl() + fileName;
                result.setCode(200);
                result.setResult(1);
                result.setMsg(url);
            } else {
                result.setCode(300);
                result.setResult(0);
                result.setMsg("操作失败");
            }
        } catch (Exception ex) {
            result.setCode(500);
            result.setResult(0);
            result.setMsg("操作异常");
            ex.printStackTrace();
        }
        return result;
    }


    @ResponseBody
    @RequestMapping(value = "/get_list_org")
    public GridCommon<Map> GetListOrg(HttpServletRequest request) {
        GridCommon<Map> countlist = new GridCommon<Map>();
        try {
            int year = Integer.parseInt(request.getParameter("year"));
            int quarter = Integer.parseInt(request.getParameter("quarter"));
            String where = "";
            if (this.GetOrgListByRole() != "") {
                where = " AND orgid IN (" + this.GetOrgListByRole() + ")";
            }


            List<Map> list = iUserUATMzpdService.GetPjOrgSumList(where, year, quarter);

//            for (Map map : list) {
//
//                for (Object o : map.keySet()) {
//                    String key = o.toString();
//                    "usercount";
//                    if(key.equals("status")){
//                        String value = map.get(key).toString();
//                        if(value.equals("2")){
//
//                        }
//                    }
//                }
//
//            }

            countlist.setCurrentPage(1);
            countlist.setPageSize(10);
            countlist.setItems(list);
            countlist.setStatus(0);
            countlist.setMsg("");
        } catch (Exception e) {
            countlist.setCurrentPage(1);
            countlist.setPageSize(10);
            countlist.setItems(null);
            countlist.setStatus(1);
            countlist.setMsg("操作成功");
        }
        return countlist;
    }

    @ResponseBody
    @RequestMapping(value = "/get_org_tj")
    public UserUATBmTjEntity GetOrgTj(Long orgid, int year) {
        UserUATBmTjEntity entity = new UserUATBmTjEntity();
        try {
            entity = iUserUATMzpdService.GetBmTj(year, orgid);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return entity;
    }


    @ResponseBody
    @RequestMapping(value = "/update_mzpd_status")
    public ExceResult UpdateMzpdStatus(HttpServletRequest request, HttpServletResponse response) {
        ExceResult result = new ExceResult();
        result.setCode(400);
        result.setResult(0);
        try {
            Long mzpdid = Long.parseLong(request.getParameter("mzpdid"));
            Long userid = Long.parseLong(request.getParameter("userid"));
            int status = Integer.parseInt(request.getParameter("status"));
            int year = Integer.parseInt(request.getParameter("year"));
            int quarter = Integer.parseInt(request.getParameter("quarter"));


            int iResult = iUserUATMzpdService.UpdateUATMzpdStatus(mzpdid, userid, status, year, quarter);
            if (iResult > 0) {
                result.setCode(200);
                result.setResult(iResult);
                result.setMsg("操作成功");
            } else {
                result.setCode(300);
                result.setResult(iResult);
                result.setMsg("操作失败");
            }
        } catch (Exception ex) {
            result.setCode(500);
            result.setResult(0);
            result.setMsg("操作异常");
            ex.printStackTrace();
        }
        return result;
    }

    @ResponseBody
    @RequestMapping(value = "/update_mzpd_status_bm")
    public ExceResult UpdateMzpdStatusBm(HttpServletRequest request, HttpServletResponse response) {
        ExceResult result = new ExceResult();
        result.setCode(400);
        result.setResult(0);
        try {
            Long orgid = Long.parseLong(request.getParameter("orgid"));
            int status = Integer.parseInt(request.getParameter("status"));
            int year = Integer.parseInt(request.getParameter("year"));
            int quarter = Integer.parseInt(request.getParameter("quarter"));

            Long orgstatustjid = Long.parseLong(request.getParameter("orgstatustjid"));


            int iExit = iUserUATMzpdService.GetOrgStatusCount(orgid, year, quarter);
            if (iExit > 0) {
                result.setCode(300);
                result.setResult(0);
                result.setMsg("该部门已提交");
                return result;
            }


            //int iResult=iUserUATMzpdService.UpdateUATMzpdStatus(mzpdid, userid, status, year, quarter);
            //int iResult=iUserUATMzpdService.UpdateUATMzpdStatusBm(orgid,status,year,quarter);
            int iResult = iUserUATMzpdService.UpdateUATMzpdStatusBmNew(orgid, status, year, quarter, orgstatustjid);

            if(status == 1){
                iResult += iPyResultService.backDataByStatusGd(year,quarter);//固化季度数据
            }
            if (iResult > 0) {
                result.setCode(200);
                result.setResult(iResult);
                result.setMsg("操作成功");
            } else {
                result.setCode(300);
                result.setResult(iResult);
                result.setMsg("操作失败");
            }
        } catch (Exception ex) {
            result.setCode(500);
            result.setResult(0);
            result.setMsg("操作异常");
            ex.printStackTrace();
        }
        return result;
    }


}
